import sun.misc.Unsafe;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @author 龙小虬
 * @date 2021/4/23 10:43
 */
public class Main extends Thread {
    private static AtomicLong atomicLong = new AtomicLong();

    @Override
    public void run() {
        while (atomicLong.get()<1000){
            System.out.println(Thread.currentThread().getName() + "," + atomicLong.incrementAndGet());
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Long startTime=System.currentTimeMillis();
        Main main1 = new Main();
        Main main2 = new Main();
        main1.start();
        main2.start();
        main1.join();
        main2.join();
        Long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }
}
